//
//  PlayerView.m
//  NineGroupProject
//
//  Created by dllo on 15/12/25.
//  Copyright © 2015年 lushan. All rights reserved.
//

#import "PlayerView.h"
#import "Masonry.h"

@implementation PlayerView


-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

- (void)createSubView{
    
    self.musicLabel = [[UILabel alloc]init];
    self.musicLabel.text = @"暂无歌曲,在下面的电台中选择你想听的电台吧";
    self.musicLabel.textAlignment = UITextAlignmentCenter;
    [self addSubview:self.musicLabel];
    [self.musicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(10 * HEI);
        make.right.mas_equalTo(-10 * HEI);
        make.height.mas_equalTo(20 * HEI);
    }];
    
    self.musicImage = [[UIImageView alloc]init];
    self.musicImage.image = [UIImage imageNamed:@"holderImage.jpg"];
    [self addSubview:self.musicImage];
    [self.musicImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.musicLabel.mas_left);
        make.top.equalTo(self.musicLabel.mas_bottom).offset(10 * HEI);
        make.size.mas_equalTo(100 * HEI);
    }];

    self.progressSlider = [[UISlider alloc]init];
    self.progressSlider.minimumTrackTintColor = [UIColor brownColor];
    [self.progressSlider setThumbImage:[UIImage imageNamed:@"soundSlider.png"] forState:UIControlStateNormal];
    [self addSubview:self.progressSlider];
    [self.progressSlider mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.musicImage.mas_right).offset(20 * WID);
        make.top.equalTo(self.musicImage.mas_top);
        make.right.equalTo(self.musicLabel.mas_right);
        make.height.equalTo(self.musicImage.mas_height).multipliedBy(0.3);
    }];
    
    self.presentTimeLabel = [[UILabel alloc]init];
    self.presentTimeLabel.text = @"00:00";
    [self addSubview:self.presentTimeLabel];
    [self.presentTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.progressSlider.mas_left);
        make.top.equalTo(self.progressSlider.mas_bottom).offset(10 * HEI);
        make.width.equalTo(self.musicImage.mas_width).multipliedBy(0.8);
        make.height.equalTo(self.musicImage.mas_height).multipliedBy(0.15);
    }];
    
    self.allTimeLabel = [[UILabel alloc]init];
    self.allTimeLabel.text = @"00:00";
    [self addSubview:self.allTimeLabel];
    [self.allTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.presentTimeLabel.mas_top);
        make.right.equalTo(self.progressSlider.mas_right);
        make.height.equalTo(self.presentTimeLabel.mas_height);
    }];
    
    self.startButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.startButton setImage:[UIImage imageNamed:@"lh-bofang.png"] forState:UIControlStateNormal];
    [self addSubview:self.startButton];
    [self.startButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.presentTimeLabel.mas_bottom).offset(10 * HEI);
        make.left.equalTo(self.presentTimeLabel.mas_left);
        make.size.mas_equalTo(35 * HEI);
    }];
    
    self.soundImage = [[UIImageView alloc]init];
    self.soundImage.image = [UIImage imageNamed:@"lh-yinliang.png"];
    [self addSubview:self.soundImage];
    [self.soundImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.startButton.mas_right).offset(30 * WID);
        make.top.equalTo(self.startButton.mas_top).offset(5 * HEI);
        make.size.mas_equalTo(25 * HEI);
    }];
    
    self.soundSlider = [[UISlider alloc]init];
    [self.soundSlider setThumbImage:[UIImage imageNamed:@"soundImage.png"] forState:UIControlStateNormal];
    //设置进度条最小数值
    self.soundSlider.minimumValue = 0;
    //设置进度条最大数值
    self.soundSlider.maximumValue = 10;
    //滑块默认值
    self.soundSlider.value = 1;
    [self addSubview:self.soundSlider];
    [self.soundSlider mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.soundImage.mas_right).offset(10 * WID);
        make.top.equalTo(self.soundImage.mas_top).offset(5 * HEI);
        make.right.equalTo(self.progressSlider.mas_right);
        make.height.mas_equalTo(15 * HEI);
    }];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
